package com.zj.study.file;

import com.zj.study.pojo.FinalResultVO;
import java.io.IOException;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author 赵赳
 * @since 2024/1/3 11:19
 */
@RestController
public class FileUploadController {

  /**
   * 文件上传
   *
   * @param file
   * @return
   */
  @PostMapping("/api/uploadFile")
  public FinalResultVO<Void> uploadFile(@RequestParam("file") MultipartFile file)
      throws IOException {
    var bytes = file.getBytes();
    var fileData = ExcelInputUtils.readExcel(bytes, FileData.class);
    System.out.println("fileData = " + fileData);
    return FinalResultVO.ok();
  }


}
